home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’91 / ColorHack 1991 / the hack / xxGRAF.a < prev    next >
Encoding:
Text File  |  1991-06-21  |  5.8 KB  |  221 lines  |  [TEXT/MPS ]

  1.              BLANKS        ON
  2.             STRING        ASIS
  3.  
  4.             PRINT        OFF
  5.             INCLUDE        'ToolEqu.a'
  6.             INCLUDE        'Traps.a'
  7.             INCLUDE        'SysEqu.a'
  8.             INCLUDE        'QuickEqu.a'
  9.             PRINT        ON
  10.             
  11. GRAF0        PROC        EXPORT
  12.             IMPORT        CSEARCH
  13.  
  14. LinkSize    EQU        -60
  15. xxxxxxxx    equ        -38
  16. SavBkCol    EQU        -32
  17. SavFgCol    EQU        -26
  18. theColor    equ        -20
  19. drawLength    equ        -16
  20. drawAddr    equ        -12
  21.  
  22. testLength    equ        -8
  23. startAddr    EQU        -4
  24.  
  25. ;
  26.             dc.l    0        ; grafproc 1 of 13
  27.             dc.l    0        ; grafproc 2 of 13
  28.             dc.l    0        ; grafproc 3 of 13
  29.             dc.l    0        ; grafproc 4 of 13
  30.             dc.l    0        ; grafproc 5 of 13
  31.             dc.l    0        ; grafproc 6 of 13
  32.             dc.l    0        ; grafproc 7 of 13
  33.             dc.l    0        ; grafproc 8 of 13
  34.             dc.l    0        ; grafproc 9 of 13
  35.             dc.l    0        ; grafproc 10 of 13
  36.             dc.l    0        ; grafproc 11 of 13
  37.             dc.l    0        ; grafproc 12 of 13
  38.             dc.l    0        ; grafproc 13 of 13
  39. origAddr    dc.l    0        ; stored address of original StdText procedure
  40. ;
  41. ;  PROCEDURE   StdText(byteCount: short,    +20
  42. ;                      bytePtr: Ptr,            +16
  43. ;                      xxx: Point,            +12
  44. ;                      yyy: Point)            +8
  45. ;
  46. ;
  47. DP1
  48.             LINK    A6,#LinkSize         ; set up a stack frame to address parameters
  49.             MOVEM.L D3-D7/A1-A4,-(SP)    ; save work registers
  50.             
  51.             clr.l    d3
  52.             move.w    20(a6),d3            ; get string length
  53.             move.l    16(a6),a3            ; get pointer
  54.             
  55.             clr.l    drawAddr(a6)        ; clear the early draw addr
  56. @2
  57.             clr.l    startAddr(a6)        ; clear the start address
  58.             clr.l    testLength(a6)        ; clear the length
  59. @4
  60.             clr.l    d4                    ;
  61.             move.b    (a3),d4                ;
  62.             lea.l    table1,a0            ;
  63.             add.l    d4,a0
  64.             cmpi.b    #'y',(a0)            ; is this a string character ?
  65.             bne.s    @20                    ; if not go to @20
  66.             
  67.             tst.l    startAddr(a6)        ; do we a start addr ?
  68.             bne.s    @10                    ; yes
  69.             move.l    a3,startAddr(a6)
  70. @10
  71.             addq.l    #1,testLength(a6)    ; add 1 to length
  72.             
  73.             addq.l    #1,a3                ; pt to nex byte
  74.             subq.l    #1,d3                ; sub one
  75.             bne.s    @4                    ; loop if more
  76.             bra.s    @30                    ; final check
  77.  
  78. @20
  79.             tst.l    drawAddr(a6)        ; do we a start addr ?
  80.             bne.s    @22                    ; yes
  81.             move.l    a3,drawAddr(a6)
  82. @22
  83.  
  84.             tst.l    testLength(a6)        ; did we get any ?
  85.             beq.s    @25                    ; no so skip
  86.             
  87.             bsr.s    CallSearch            ; call the searcher
  88.             move.l    a3,drawAddr(a6)        ; set the breaking byte addr
  89. @25
  90.             addq.l    #1,a3                ; pt to nex byte
  91.             subq.l    #1,d3                ; sub one
  92.             bne.s    @4                    ; loop if more
  93. @30
  94.             tst.l    testLength(a6)        ; did we get any ?
  95.             beq.s    @35                    ; no so skip
  96.             
  97.             bsr.s    CallSearch            ; call the searcher
  98.             clr.l    drawAddr(a6)        ; clear the breaking byte addr
  99. @35
  100.             bsr        DrawFinal            ; see if any more left
  101.  
  102.             MOVEM.L (SP)+,D3-D7/A1-A4    ; restore work registers
  103.             UNLK    A6                    ; unlink stack frame
  104.             MOVE.L    (SP)+,A0            ; get return address
  105.             ADD     #14,SP                ; strip parameters
  106.             JMP     (A0)                ; return to caller
  107.  
  108. DrawSome
  109.             move.w    d0,-(sp)            ; push byteCount
  110.             move.l    a0,-(sp)            ; push bytePtr
  111.             move.l    12(a6),-(sp)        ; push xxx
  112.             move.l    8(a6),-(sp)            ; push yyy
  113.             move.l    origAddr,a0            ; get orig addr
  114.             jsr        (a0)                ; call the original guy
  115.             rts
  116.  
  117. CallSearch
  118.             clr.l    -(sp)                ; result
  119.             move.l    startAddr(a6),-(sp)    ; the string addr
  120.             move.l    testLength(a6),-(sp) ; the string length
  121.             pea.l    theColor(a6)        ; pt to the color
  122.             jsr        CSEARCH                ; search for the string
  123.             
  124.             move.l    (sp)+,d4            ; is this a hit
  125.             beq.s    @600                ; no
  126. ;
  127. ;        ok, we got a hit, so we do a two stage draw, first default, then in color
  128. ;
  129.             tst.l    drawAddr(a6)        ; is there any previous to draw ?
  130.             beq.s    @500                ; no
  131.             
  132.             move.l    startAddr(a6),d0
  133.             sub.l    drawAddr(a6),d0        ; 
  134.             move.l    drawAddr(a6),a0        ; 
  135.             bsr.s    DrawSome
  136. @500
  137.             PEA        SavFgCol(A6)        ; push a pointer to save area
  138.             _GetForeColor                ; get the current color
  139.             PEA        SavBkCol(A6)        ; 
  140.             _GetBackColor                ;
  141.             
  142.             PEA        theColor(a6)        ; point to color
  143.             _RGBForeColor                ;
  144.             move.l    startAddr(a6),a0    ; get pointer
  145.             move.l    testLength(a6),d0    ; get length
  146.             bsr        DrawSome
  147.             
  148.             PEA        savBkCol(A6)        ; 
  149.             _RGBBackColor                ;
  150.             PEA        savFgCol(A6)        ; 
  151.             _RGBForeColor                ;
  152.             
  153.             clr.l    drawAddr(a6)
  154.             bra.s    @700
  155. @600
  156. ;                here we do a one stage draw
  157.             tst.l    drawAddr(a6)        ;
  158.             beq.s    @650                ; no, no first part to draw
  159.             
  160.             move.l    startAddr(a6),d0    ;
  161.             sub.l    drawAddr(a6),d0        ;
  162.             move.l    drawAddr(a6),a0        ;
  163.             bsr.s    DrawSome            ;
  164. @650
  165.             move.l    startAddr(a6),a0    ;
  166.             move.l    testLength(a6),d0    ; 
  167.             bsr.s    DrawSome            ;
  168. @700
  169.             clr.l    drawAddr(a6)        ; clear the early draw addr
  170.             clr.l    startAddr(a6)        ; clear the start address
  171.             clr.l    testLength(a6)        ; clear the length
  172.             rts
  173.  
  174. DrawFinal
  175.             tst.l    drawAddr(a6)        ; is there any previous to draw ?
  176.             beq.s    @800                ; no
  177.             
  178.             move.l    a3,d0                ;
  179.             sub.l    drawAddr(a6),d0        ; 
  180.             move.l    drawAddr(a6),a0        ; 
  181.             bsr.s    DrawSome
  182. @800
  183.             rts
  184.             
  185.  
  186.  
  187. mockup1        dc.w    $F2D7,$0856,$84EC        ; magenta
  188.             dc.w    $0000,$0000,$D400        ; blue
  189.             dc.w    $0000,$8000,$11B0        ; green
  190.             dc.w    $0241,$AB54,$EAFF        ; cyan
  191.             dc.w    $DD6B,$08C2,$06A2        ; red
  192.  
  193. ;    0    black      $0000    $0000    $0000
  194. ;    1    yellow     $FC00    $F37D    $052F
  195. ;    2    magenta    $F2D7    $0856    $84EC
  196. ;    3    red        $DD6B    $08C2    $06A2
  197. ;    4    cyan       $0241    $AB54    $EAFF
  198. ;    5    green      $0000    $8000    $11B0
  199. ;    6    blue       $0000    $0000    $D400
  200. ;    7    white      $FFFF    $FFFF    $FFFF
  201.  
  202.             string asis
  203. table1        dc.b    'nnnnnnnnnnnnnnnn'    ; 00-0f ................
  204.             dc.b    'nnnnnnnnnnnnnnnn'    ; 10-1f ................
  205.             dc.b    'nnnynnnnnnnnnnnn'    ; 20-2f ...#............
  206.             dc.b    'yyyyyyyyyynnnnnn'    ; 30-3f 0123456789......
  207.             dc.b    'nyyyyyyyyyyyyyyy'    ; 40-4f .ABCDEFGHIJKLMNO
  208.             dc.b    'yyyyyyyyyyynnnny'    ; 50-5f PQRSTUVWXYZ...._
  209.             dc.b    'nyyyyyyyyyyyyyyy'    ; 60-6f .abcdefghijklmno
  210.             dc.b    'yyyyyyyyyyynnnnn'    ; 70-7f pqrstuvwxyz.....
  211.             dc.b    'nnnnnnnnnnnnnnnn'    ; 80-8f ................
  212.             dc.b    'nnnnnnnnnnnnnnnn'    ; 90-9f ................
  213.             dc.b    'nnnnnnnnnnnnnnnn'    ; a0-af ................
  214.             dc.b    'nnnnnnnnnnnnnnnn'    ; b0-bf ................
  215.             dc.b    'nnnnnnnnnnnnnnnn'    ; c0-cf ................
  216.             dc.b    'nnnnnnnnnnnnnnnn'    ; d0-df ................
  217.             dc.b    'nnnnnnnnnnnnnnnn'    ; e0-ef ................
  218.             dc.b    'nnnnnnnnnnnnnnnn'    ; f0-ff ................
  219.             
  220.             endp
  221.             end